﻿namespace SharpF2.Components
{
	using System.Collections.Generic;
	using System.Linq;
	using System.Windows.Input;

	/// <summary>
	/// Interaction logic for IntegerBox
	/// </summary>
	public class FileNameBox : TextBoxIntelliSense
	{
		#region Private Attributes

		private static readonly IEnumerable<char> invalidChar = new HashSet<char>
		                                                        	{'/', '\\', ':', '*', '?', '"', '<', '>', '|'};

		#endregion

		#region Private Members

		private static bool AreAllValidChars(IEnumerable<char> text)
		{
			return invalidChar.Intersect(text).Count() <= 0;
		}

		#endregion

		#region Protected Members

		protected override void OnPreviewTextInput(TextCompositionEventArgs e)
		{
			e.Handled = !AreAllValidChars(e.Text);
			base.OnPreviewTextInput(e);
		}

		#endregion
	}
}